package com.rf.richfitwheel.dyn.business.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.rf.richfitwheel.dyn.business.entity.SysBusinessDesignerComponent;
import com.rf.richfitwheel.dyn.business.entity.SysFormDesigner;
import com.rf.richfitwheel.dyn.business.mapper.SysBusinessDesignerComponentMapper;
import com.rf.richfitwheel.dyn.business.service.SysBusinessDesignerComponentService;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 表单组件明细 服务层实现。
 *
 * @author richfitwheel
 * @since 2025-02-18
 */
@Service
public class SysBusinessDesignerComponentServiceImpl extends ServiceImpl<SysBusinessDesignerComponentMapper, SysBusinessDesignerComponent>  implements SysBusinessDesignerComponentService{

    /**
     * 根据表单设计id获取表单下的组件信息
     *
     * @param designerId 表单信息
     * @return 表单下的组件信息
     */
    @Override
    public List<SysBusinessDesignerComponent> queryByDesignerId(String designerId) {
        QueryWrapper queryWrapper = QueryWrapper.create().from(SysBusinessDesignerComponent.class)
                .join(SysFormDesigner.class).on(
                        wrapper -> wrapper.where(SysBusinessDesignerComponent::getComponentId)
                                .eq(SysFormDesigner::getId)
                ).where(SysBusinessDesignerComponent::getDesignerId).eq(designerId);
        queryWrapper.orderBy(SysBusinessDesignerComponent::getOrderNum);
        return this.list(queryWrapper);
    }
}
